`
https://leetcode.cn/problems/solving-questions-with-brainpower/
`

/**
 * @param {number[][]} questions
 * @return {number}
 */
var mostPoints = function (questions) {
  const n = questions.length
  // dp[i] 表示从当前题目做起能获得的最多分数
  const dp = new Array(n + 1).fill(0)

  for (let i = n - 1; i >= 0; i--) {
    // 后面没有那么多可以跳过的题，会出现越界
    if (i + questions[i][1] + 1 >= n) {
      dp[i] = Math.max(questions[i][0], dp[i + 1])
      continue
    }
    dp[i] = Math.max(
      // 做题
      questions[i][0] + dp[i + questions[i][1] + 1],
      // 不做题
      dp[i + 1]
    )
  }

  return dp[0]
};

// test
console.log(mostPoints([[3, 2], [4, 3], [4, 4], [2, 5]])) // 3